home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** ----------------------------------------------- ** $VER: MUIFontCatalog V3.04 (26 May 2001) ** ©1996-2001 Michael Merkel ** ----------------------------------------------- */ SIGNAL ON SYNTAX SIGNAL ON HALT SIGNAL ON BREAK_C OPTIONS RESULTS /* TRACE ALL */ /* ** first of all add the needed libraries */ IF ~show("L","rmh.library") THEN IF ~AddLib("rmh.library", 0, -30) THEN EXIT IF ~show("L","rxasl.library") THEN IF ~AddLib("rxasl.library", 0, -30) THEN EXIT IF ~show("L","rxmui.library") THEN IF ~AddLib("rxmui.library", 0, -30) THEN EXIT /* ** DEBUG MODE!!! */ Call rxMuiOpt("DEBUGMODE SHOWERR") /* ** Make sure rexx support is opened */ IF ~SHOW('L','rexxsupport.library') THEN CALL ADDLIB('rexxsupport.library',0,-30) IF ~SHOW('L','softlogik:libs/slarexxsupport.library') THEN CALL ADDLIB('softlogik:libs/slarexxsupport.library',0,-30) IF ~SHOW('P','PAGESTREAM') THEN DO CALL ShowRequester("Start PageStream first!", "Of course...") Exit END ADDRESS 'PAGESTREAM' pgsInstallDir = 'PageStream:Scripts/MUIFontCatalog' pgsName = 'MUIFontCatalog' pgsVersion = 'V3.04' pgsAuthor = 'Michael Merkel' pgsCopy = '©1996-2001 Michael Merkel' pgsLVer = '3.00' pgsDate = '05/26/2001' pgsPic = pgsInstallDir || '/MUIFontCatalog.pic' standardPrefs = pgsInstallDir || '/MUIFontCatalog.prefs' TRUE = 1 FALSE = 0 /* ** default settings */ Call SetDefaultPrefs /* ** do some checks before */ Call CheckRoutines /* ** load prefs */ Call LoadPrefs(standardPrefs) Call BuildGUI muiBusyWinOpen = FALSE /* ** open the window */ 'LOCKINTERFACE TRUE' Call Set("muiWin", "OPEN", 1) Call GetAttr("muiWin", "OPEN", "o") IF (o = 0) THEN DO Say "can't open window" EXIT END Call Set("muiWin", "SLEEP", 1) Call PrefsWindowSet() Call GetFontList() Call Set("muiWin", "SLEEP", 0) Call EventLoop() Call PrefsWindowGet() Call Set("muiWin", "OPEN", 0) Call BusyOpen("doing fonts...", 2, "...\n...", "...\n...", "", anzFonts, 100, 0) Call FontCatalog() Call CleanUp() EXIT /* /// AddObject(name) */ AddObject: PARSE ARG name Call BusyText(1, "%c%bplacing font%n\n%c"|| name ||"%n") Call BusyText(2, "%c%bplacing%n\n%c%n") Call BusyProgress(2, 30) IF (BusyHandle(1, fontNum, 0, 0) = 1) THEN DO Call CleanUp() EXIT END d1 = startx d2 = starty oldStartx = startx oldStarty = starty Call DrawTextObject(name) pwidth = posi.right - posi.left pheight = posi.bottom - posi.top /* ** remember maximum width and height of the sample */ IF (pheight > maxheight) THEN maxheight = pheight IF (pwidth > maxwidth) THEN maxwidth = pwidth /* recalculate the textframe -> no fixed fontsize! */ IF (prefs.PV_ffSize = 0) THEN DO /* original aspect of width:height of one generated sample */ gsf = pwidth / pheight IF (gsf > psf) THEN factor = (psx - 2*(sbw + thumbSpace)) / pwidth ELSE factor = (psynt - 2*(sbw + thumbSpace)) / pheight newpwidth = (factor * pwidth) newpheight = (factor * pheight) centerdeltax = (psx - newpwidth ) / 2 centerdeltay = (psynt - newpheight) / 2 d3 = d1 + psx d4 = d2 + psy IF (prefs.PV_vertical = 0) THEN DO /* ** vertical mode is off: ** 1. check if too far right -> next row */ IF ((d3 - 1) > (pagesizex - rightgap - pbw - gap)) THEN DO startx = leftgap + pbw + gap starty = d4 + gap d1 = startx d2 = starty d3 = d1 + psx d4 = d2 + psy END /* ** 2. check if too far down -> next page */ IF ((d4 - 1) > (pagesizey - bottomgap - pbw - (lsize+1) - gap)) THEN DO startx = leftgap + pbw + gap starty = topgap + pbw + gap lastpic = 1 /* last picture already placed! print or flip page and go on... */ fontNum = fontNum - 1 'DELETEOBJECT OBJECTID 'txtid' WINDOW "'oldwinname'"' RETURN END startx = d1 + psx + gap END ELSE DO /* ** vertical mode is on: ** 1. check if too far down -> next column */ IF ((d4 - 1) > (pagesizey - bottomgap - pbw - (lsize+1) - gap)) THEN DO startx = d3 + gap starty = topgap + pbw + gap d1 = startx d2 = starty d3 = d1 + psx d4 = d2 + psy END /* ** 2. check if too far right -> next page */ IF ((d3 - 1) > (pagesizex - rightgap - pbw - gap)) THEN DO startx = leftgap + pbw + gap starty = topgap + pbw + gap lastpic = 1 /* last picture already placed! print or flip page and go on... */ fontNum = fontNum - 1 'DELETEOBJECT OBJECTID 'txtid' WINDOW "'oldwinname'"' RETURN END starty = d2 + psy + gap END /* calculate the new position and dimensions of the sample */ newl = d1 + centerdeltax newt = d2 + centerdeltay newr = newl + newpwidth newb = newt + newpheight 'EDITTEXTOBJ POSITION 'newl newt newr newb' OBJECTID 'txtid' WINDOW "'oldwinname'"' END ELSE DO /* ** calculate textframes -> fixed fontsize! */ factor = 1.0 d3 = d1 + pwidth + 2*(sbw + thumbSpace) d4 = d2 + pheight + 2*(sbw + thumbSpace) + (txtSize + 1) IF (prefs.PV_vertical = 0) THEN DO /* ** vertical mode is off: ** 1. check if too far right -> next row */ IF ((d3 - 1) > (pagesizex - rightgap - pbw - gap)) THEN DO startx = leftgap + pbw + gap starty = d2 + maxheight + 2*(sbw + thumbSpace) + (txtsize + 1) + gap d1 = startx d2 = starty d3 = d1 + pwidth + 2*(sbw + thumbSpace) d4 = d2 + pheight + 2*(sbw + thumbSpace) + (txtsize+1) IF ((d3 - 1) > (pagesizex - rightgap - pbw - gap)) THEN DO IF (prefs.errorSkip = 0) THEN DO res = SizeError() IF (res = 2) THEN DO prefs.errorSkip = 1 END END IF (prefs.errorSkip = 1) | (res = 1) THEN DO Call BusyText(2, "%c%bskipping current picture...%n\n%c%n") Call BusyProgress(2, 100) 'DELETEOBJECT OBJECTID 'txtid' WINDOW "'oldwinname'"' startx = oldStartx starty = oldStarty Return 0 END END maxheight = 0 maxwidth = 0 END /* ** 2. check if too far down -> next page */ IF ((d4 - 1) > (pagesizey - bottomgap - pbw - (lSize+1) - gap)) THEN DO startx = leftgap + pbw + gap starty = topgap + pbw + gap IF ((starty + pheight + 2*(sbw + thumbSpace) + (txtsize + 1)) > (pagesizey - bottomgap - pbw - (lSize+1) - gap)) THEN DO IF (prefs.errorSkip = 0) THEN DO res = SizeError() IF (res = 2) THEN DO prefs.errorSkip = 1 END END IF (prefs.errorSkip = 1) | (res = 1) THEN DO Call BusyText(2, "%c%bskipping current picture...%n\n%c%n") Call BusyProgress(2, 100) 'DELETEOBJECT OBJECTID 'txtid' WINDOW "'oldwinname'"' startx = oldStartx starty = oldStarty Return 0 END END fontNum = fontNum - 1 maxheight = 0 maxwidth = 0 lastpic = 1 'DELETEOBJECT OBJECTID 'txtid' WINDOW "'oldwinname'"' RETURN END startx = d3 + gap END ELSE DO /* ** vertical mode is on: ** 1. check if too far down -> next column */ IF ((d4 - 1) > (pagesizey - bottomgap - pbw - (lSize+1) - gap)) THEN DO startx = d1 + maxwidth + 2*(sbw + thumbSpace) + gap starty = topgap + pbw + gap d1 = startx d2 = starty d3 = d1 + pwidth + 2*(sbw + thumbSpace) d4 = d2 + pheight + 2*(sbw + thumbSpace) + (txtsize+1) IF ((d4 - 1) > (pagesizey - bottomgap - pbw - (lSize+1) - gap)) THEN DO IF (prefs.errorSkip = 0) THEN DO res = SizeError() IF (res = 2) THEN DO prefs.errorSkip = 1 END END IF (prefs.errorSkip = 1) | (res = 1) THEN DO Call BusyText(2, "%c%bskipping current picture...%n\n%c%n") Call BusyProgress(2, 100) 'DELETEOBJECT OBJECTID 'txtid' WINDOW "'oldwinname'"' startx = oldStartx starty = oldStarty Return 0 END END maxheight = 0 maxwidth = 0 END /* ** 2. check if too far right -> next page */ IF ((d3 - 1) > (pagesizex - rightgap - pbw - gap)) THEN DO startx = leftgap + pbw + gap starty = topgap + pbw + gap IF ((startx + pwidth + 2*(sbw + thumbSpace)) > (pagesizex - rightgap - pbw - gap)) THEN DO IF (prefs.errorSkip = 0) THEN DO res = SizeError() IF (res = 2) THEN DO prefs.errorSkip = 1 END END IF (prefs.errorSkip = 1) | (res = 1) THEN DO Call BusyText(2, "%c%bskipping current picture...%n\n%c%n") Call BusyProgress(2, 100) 'DELETEOBJECT OBJECTID 'txtid' WINDOW "'oldwinname'"' startx = oldStartx starty = oldStarty Return 0 END END fontNum = fontNum - 1 maxheight = 0 maxwidth = 0 lastpic = 1 'DELETEOBJECT OBJECTID 'txtid' WINDOW "'oldwinname'"' RETURN END starty = d4 + gap END /* ** calculate the new position and dimensions of the sample */ newl = d1 + (sbw + thumbSpace) newt = d2 + (sbw + thumbSpace) newr = newl + pwidth newb = newt + pheight 'EDITTEXTOBJ POSITION 'newl newt newr newb' OBJECTID 'txtid' WINDOW "'oldwinname'"' END IF (txtsize > 0) THEN DO Call BusyText(2, "%c%bsetting%n\n%cfontname and size%n") Call BusyProgress(2, 60) /* print the fontname and size */ d41 = d4 - (txtsize+1) 'DRAWTEXTOBJ 'd1 d41' INFRONT WINDOW "'oldwinname'"' txtid = RESULT 'SELECTTEXT INOBJECT 'txtid' WINDOW "'oldwinname'"' 'BEGINCOMMANDCAPTURE' 'SETTRACKTABLE NONE' 'SETLEADING RELATIVE 100%' 'SETTYPESIZE 'txtsize 'SETPARAGRAPHSTYLE "FontName"' 'ENDCOMMANDCAPTURE' sizetxt = Trunc( ffs_size * factor, 1 ) sizetxt = ' ['sizetxt||'pt ]' 'INSERT "'name||sizetxt'" WINDOW "'oldwinname'"' 'GETTEXTOBJ POSITION txtpos OBJECTID 'txtid' WINDOW "'oldwinname'"' txtp2.left = txtpos.left txtp2.top = txtpos.top txtp2.bottom = txtpos.bottom txtp2.right = txtpos.right txtwidth = txtp2.right - txtp2.left IF (txtwidth > (d3-d1)) THEN 'EDITTEXTOBJ POSITION 'txtp2.left' 'txtp2.top' 'd3' 'txtp2.bottom' OBJECTID 'txtid' WINDOW "'oldwinname'"' END Call BusyText(2, "%c%bdrawing%n\n%cborder around sample%n") Call BusyProgress(2, 80) /* ** draw the border for the sample */ IF (sbw > 0) THEN DO d11 = d1 + sbw/2 d21 = d2 + sbw/2 d31 = d3 - sbw/2 d41 = d4 - (txtsize+1) - sbw/2 'DRAWBOX 'd11 d21 d31 d41' WINDOW "'oldwinname'"' dummy = RESULT 'SETSTROKEWEIGHT 'sbw' OBJECTID 'dummy 'SETSTROKEJOIN BEVEL OBJECTID 'dummy END nppp = nppp + 1 Return /* /// */ /* /// BuildGUI() */ BuildGUI: /* ** Create the rxMUI GUI ** -------------------- */ /* ** first of all the let's define the application object */ muiApp.Title = pgsName muiApp.Version = "$VER: "|| pgsVersion ||' ('|| pgsDate ||')' muiApp.Copyright = pgsCopy muiApp.Author = pgsAuthor muiApp.Description = "Create font catalogs within PageStream" muiApp.Base = pgsName muiApp.diskobject = pgsName muiApp.ctrlc = 1 muiApp.menustrip = "muiMenuStrip" muiApp.subwindow = "muiWin" /* ** let's define the window */ muiWin.ID = "MAIN" muiWin.Title = pgsName pgsVersion ||' ('|| pgsDate ||') - '|| pgsCopy muiWin.Contents = "muiMainGroup" /* ** define the menu */ muiMenuStrip.0 = "muiMenuProject" muiMenuProject.Title = "Project" muiMenuProject.Class = "MENU" muiMenuProject.0 = MenuItem("muiMenuAbout", "About...", "?") muiMenuProject.1 = MenuItem("muiMenuAboutrxMUI","About RxMUI..." ) muiMenuProject.2 = MenuItem("muiMenuAboutMUI", "About MUI..." ) muiMenuProject.3 = MenuItem("", "BAR" ) muiMenuProject.4 = MenuItem("muiMenuQuit", "Quit", "Q") muiMenuStrip.1 = "muiMenuPrefs" muiMenuPrefs.Title = "Prefs" muiMenuPrefs.Class = "MENU" muiMenuPrefs.0 = MenuItem("muiMenuPrefsMUI", "MUI...", "M") muiMenuPrefs.1 = MenuItem("", "BAR") muiMenuPrefs.2 = MenuItem("muiMenuLoad", "Load", "L") muiMenuPrefs.3 = MenuItem("muiMenuSave", "Save", "S") muiMenuPrefs.4 = MenuItem("muiMenuSaveAs", "Save As...", "A") res = NewObj("MENUSTRIP", "muiMenuStrip") IF (res ~= 0) THEN Call Err(res) /* ** let's define the window contents */ tab = 0 muiMainGroup.0 = "muiGroup0" muiGroup0.Class = "GROUP" muiGroup0.Frame = "GROUP" muiGroup0.Horiz = 0 muiGroup0.0 = "muiGroup00" muiGroup00.Class = "GROUP" muiGroup00.Horiz = 1 muiGroup00.Frame = "GROUP" muiGroup00.Background = "FILLBACK" muiGroup00.0 = HSpace() muiGroup00.1 = "muiBITMAP" muiBITMAP.Class = "BITMAP" muiBITMAP.Precision = "ICON" muiBITMAP.File = pgsPic muiBITMAP.InputMode = "RelVerify" muiBITMAP.Frame = "BUTTON" muiGroup00.2 = Label(ParseText('%c%b%8'|| pgsName pgsVersion ||'%n\n'|| pgsCopy)) muiGroup00.3 = HSpace() muiGroup0.1 = "muiGroupPage00" muiGroupPage00.Class = "GROUP" muiGroupPage00.Horiz = 1 muiGroupPage00.0 = "muiPagerList" muiPagerList.Class = "NLISTVIEW" muiPagerList.List = "pagerList" muiPagerList.Weight = 20 pagerList.Class = "NLIST" pagerList.List = "pagerList" pagerList.0 = "Page" pagerList.1 = "Samples" pagerList.2 = "Printer/Files" pagerList.3 = "Fonts" muiGroupPage00.1 = MakeObj(,"Balance",) muiGroupPage00.2 = "muiPager" muiPager.Class = "GROUP" muiPager.Weight = 50 muiPager.PageMode = 1 /*---------------------------------------------*/ muiPager.tab = "muiTabPage"; tab = tab + 1 muiTabPage.Class = "GROUP" muiTabPage.0 = VSpace() muiTabPage.1 = "muiTabPage0" muiTabPage0.Class = "GROUP" muiTabPage0.Frame = "GROUP" muiTabPage0.FrameTitle = "FontCatalog sizes" muiTabPage0.Background = "BACKGROUND" muiTabPage0.Horiz = 1 muiTabPage0.0 = "muiTabPage00" muiTabPage00.Class = "GROUP" muiTabPage00.Columns = 4 muiTabPage00.0 = Label("Top") muiTabPage00.1 = String("g_top") muiTabPage00.2 = Label("Left") muiTabPage00.3 = String("g_left") muiTabPage00.4 = Label("Bottom") muiTabPage00.5 = String("g_bottom") muiTabPage00.6 = Label("Right") muiTabPage00.7 = String("g_right") muiTabPage0.1 = Button("g_grabMP", "grab MP") muiTabPage.2 = VSpace(10) muiTabPage.3 = "muiTabPage1" muiTabPage1.Class = "GROUP" muiTabPage1.Frame = "GROUP" muiTabPage1.FrameTitle = "Page" muiTabPage1.Background = "BACKGROUND" muiTabPage1.Horiz = 1 muiTabPage1.0 = Label("page border width") muiTabPage1.1 = String("g_pbw") muiTabPage1.2 = Label("text size") muiTabPage1.3 = String("g_lsize") muiTabPage.4 = VSpace() /*---------------------------------------------*/ muiPager.tab = "muiTabSample"; tab = tab + 1 muiTabSample.Class = "GROUP" muiTabSample.0 = "muiTabSample0" muiTabSample0.Class = "GROUP" muiTabSample0.Frame = "GROUP" muiTabSample0.FrameTitle = "Sample sizes" muiTabSample0.Background = "BACKGROUND" muiTabSample0.0 = "G_FFSIZE" g_ffsize.Class = "CYCLE" g_ffsize.Entries = "variable size|fixed size" g_ffsize.Selected = 0 muiTabSample0.1 = "muiTabSample00" muiTabSample00.Class = "GROUP" muiTabSample00.Horiz = 1 muiTabSample00.0 = "muiTabSample000" muiTabSample000.Class = "GROUP" muiTabSample000.0 = "muiTabSample000T0" muiTabSample000T0.Class = "TEXT" muiTabSample000T0.Contents = ParseText('%c%8Number of fonts per page%n') muiTabSample000.1 = "muiTabSample0000" muiTabSample0000.Class = "GROUP" muiTabSample0000.Columns = 2 muiTabSample0000.0 = Label(ParseText('#x:')) muiTabSample0000.1 = "G_X_NUM" g_x_num.Class = "SLIDER" g_x_num.Min = 1 g_x_num.Max = 40 g_x_num.Level = 1 muiTabSample0000.2 = Label(ParseText('#y:')) muiTabSample0000.3 = "G_Y_NUM" g_y_num.Class = "SLIDER" g_y_num.Min = 1 g_y_num.Max = 40 g_y_num.Level = 1 muiTabSample00.1 = "muiTabSample001" muiTabSample001.Class = "GROUP" muiTabSample001.Disabled = 1 muiTabSample001.0 = "muiTabSample001T0" muiTabSample001T0.Class = "TEXT" muiTabSample001T0.Contents = ParseText('%c%8Fixed fontsize%n') muiTabSample001.1 = String("g_f_size") muiTabSample0.2 = "muiTabSample01" muiTabSample01.Class = "GROUP" muiTabSample01.Horiz = 1 muiTabSample01.0 = Checkmark(g_vertical) muiTabSample01.1 = Label(ParseText('vertical mode')) muiTabSample01.2 = HSpace() muiTabPage.5 = VSpace() muiTabSample.1 = VSpace(10) muiTabSample.2 = "muiTabSample1" muiTabSample1.Class = "GROUP" muiTabSample1.Frame = "GROUP" muiTabSample1.FrameTitle = "Thumbnail" muiTabSample1.Background = "BACKGROUND" muiTabSample1.0 = "muiTabSample10" muiTabSample10.Class = "GROUP" muiTabSample10.Columns = 4 muiTabSample10.0 = Label("border width") muiTabSample10.1 = String("g_sbw") muiTabSample10.2 = Label("inner space") muiTabSample10.3 = String("g_thumbSpace") muiTabSample10.4 = Label("gap") muiTabSample10.5 = String("g_gap") muiTabSample10.6 = Label("font size") muiTabSample10.7 = String("g_font") muiTabSample1.1 = "muiTabSample11" muiTabSample11.Class = "GROUP" muiTabSample11.Horiz = 0 muiTabSample11.0 = "G_PRINTWHAT" g_printwhat.Class = "CYCLE" g_printwhat.Entries = "user defined ->|print all chars|use textfile" g_printwhat.Selected = 0 muiTabSample11.1 = "muiTabSample111" muiTabSample111.Class = "GROUP" muiTabSample111.Frame = "GROUP" muiTabSample111.FrameTitle = "sample text" muiTabSample111.0 = "g_fSampleCycle" g_fSampleCycle.Class = "CYCLE" g_fSampleCycle.Entries = "%FONTNAME/%FN - name of current font" muiTabSample111.1 = "g_fSample" g_fSample.Class = "TEXTINPUTSCROLL" g_fSample.Frame = "STRING" g_fSample.MultiLine = 1 g_fSample.MaxLen = 2 g_fSample.MaxLines = 2 g_fSample.Lines = 1 g_fSample.Style = "MUI" g_fSample.Contents = ParseText("\%FONTNAME\nabc\nABC") g_fSample.Editable = 1 /*---------------------------------------------*/ muiPager.tab = "muiTabFile"; tab = tab + 1 muiTabFile.Class = "GROUP" muiTabFile.Columns = 2 muiTabFile.0 = HSpace(1) muiTabFile.1 = VSpace() muiTabFile.2 = Label("output scale") muiTabFile.3 = "G_SCALE" g_scale.Class = "CYCLE" g_scale.ControlChar = "s" g_scale.Entries = "actual size|scaled to fit" g_scale.Selected = 0 muiTabFile.4 = HSpace(1) muiTabFile.5 = VSpace(5) muiTabFile.6 = Label("filename for saving") muiTabFile.7 = "G_SDIRASL" g_sdirasl.Class = "POPASL" g_sdirasl.Type = "FILE" g_sdirasl.Title = "FILE loading..." g_sdirasl.PositiveText = "load..." g_sdirasl.NegativeText = "cancel..." g_sdirasl.RejectIcons = 1 g_sdirasl.String = String("g_sdir") muiTabFile.8 = HSpace(1) muiTabFile.9 = VSpace(5) muiTabFile.10 = Label("textfile for fontsamples") muiTabFile.11 = "G_STEXTASL" g_stextasl.Class = "POPASL" g_stextasl.Type = "FILE" g_stextasl.Title = "FILE loading..." g_stextasl.PositiveText = "load..." g_stextasl.NegativeText = "cancel..." g_stextasl.RejectIcons = 1 g_stextasl.String = String("g_stext") muiTabFile.12 = HSpace(1) muiTabFile.13 = VSpace() /*---------------------------------------------*/ muiPager.tab = "muiTabFont"; tab = tab + 1 muiTabFont.Class = "GROUP" muiTabFont.Columns = 2 muiTabFont.0 = "availText" availText.Class = "TEXT" availText.Contents = "Hallo" muiTabFont.1 = "selectText" selectText.Class = "TEXT" selectText.Contents = "Hallo" muiTabFont.2 = "muiTabFontNL0" muiTabFontNL0.Class = "NLISTVIEW" muiTabFontNL0.List = "G_AVAIL" g_avail.Class = "NLIST" g_avail.AdjustHeight = 1 g_avail.MultiSelect = "DEFAULT" g_avail.Title = ParseText('%cfonts available%n') g_avail.TitleClick = 1 g_avail.DragType = "DEFAULT" g_avail.DragSortable = 1 g_avail.ShowDropMark = 1 g_avail.DropMark = 1 muiTabFont.3 = "muiTabFontNL1" muiTabFontNL1.Class = "NLISTVIEW" muiTabFontNL1.List = "G_SELECT" g_select.Class = "NLIST" g_select.AdjustHeight = 1 g_select.MultiSelect = "DEFAULT" g_select.Title = ParseText('%cprintlist%n') g_select.TitleClick = 2 g_select.DragType = "DEFAULT" g_select.DragSortable = 1 g_select.ShowDropMark = 1 muiTabFont.4 = Button("g_AvailAll","Select all") muiTabFont.5 = Button("g_SelectAll","Select all") muiMainGroup.1 = "G_ACTION" g_action.Class = "CYCLE" g_action.ControlChar = "a" g_action.Entries = "collect|print|save" g_action.Selected = 0 muiMainGroup.2 = "muiButtonGroup" muiButtonGroup.Class = "GROUP" muiButtonGroup.Columns = 2 muiButtonGroup.0 = Button("G_OK", "_Ok" ) muiButtonGroup.1 = Button("G_CANCEL", "_Cancel") /* ** create all */ Call NewObj("APPLICATION","muiApp") /* ** window close gadget means quit... */ Call Notify("muiWin", "CLOSEREQUEST", 1, "muiApp", "RETURNID", "QUIT") /* ** Cycles */ Call Notify("G_FFSIZE", "ACTIVE", 0, "muiTabSample001", "SET", "DISABLED", 1) Call Notify("G_FFSIZE", "ACTIVE", 0, "muiTabSample000", "SET", "DISABLED", 0) Call Notify("G_FFSIZE", "ACTIVE", 1, "muiTabSample001", "SET", "DISABLED", 0) Call Notify("G_FFSIZE", "ACTIVE", 1, "muiTabSample000", "SET", "DISABLED", 1) Call Notify("G_PRINTWHAT", "ACTIVE", 0, "muiTabSample111", "SET", "DISABLED", 0) Call Notify("G_PRINTWHAT", "ACTIVE", 1, "muiTabSample111", "SET", "DISABLED", 1) Call Notify("G_PRINTWHAT", "ACTIVE", 2, "muiTabSample111", "SET", "DISABLED", 1) /* ** Ok and Cancel Buttons... */ Call Notify("G_CANCEL", "PRESSED", 0, "muiApp", "RETURNID") Call Notify("G_OK", "PRESSED", 0, "muiApp", "RETURNID") Call Notify("G_GRABMP", "PRESSED", 0, "muiApp", "RETURNID") /* ** Menu events... */ Call Notify("muiMenuLoad", "MENUTRIGGER", "EVERYTIME", "muiApp", "RETURNID") Call Notify("muiMenuSave", "MENUTRIGGER", "EVERYTIME", "muiApp", "RETURNID") Call Notify("muiMenuSaveAs", "MENUTRIGGER", "EVERYTIME", "muiApp", "RETURNID") Call Notify("muiMenuPrefsMUI", "MENUTRIGGER", "EVERYTIME", "muiApp", "OpenConfigWindow") Call Notify("muiMenuAbout", "MENUTRIGGER", "EVERYTIME", "muiApp", "ABOUT", "muiWin") Call Notify("muiMenuAboutrxMUI","MENUTRIGGER", "EVERYTIME", "muiApp", "ABOUTRXMUI", "muiWin") Call Notify("muiMenuAboutMUI", "MENUTRIGGER", "EVERYTIME", "muiApp", "ABOUTMUI", "muiWin") Call Notify("muiMenuQuit", "MENUTRIGGER", "EVERYTIME", "muiApp", "RETURNID") /* ** Button click -> about */ Call Notify("muiBitmap", "PRESSED", 0, "muiApp", "ABOUT", "muiWin") /* ** Drag'n'Drop for the lists */ Call DandD("g_avail", "g_select", "AUTO REMOVE") Call DandD("g_select", "g_avail", "AUTO REMOVE") /* ** Sort lists on title click */ Call Notify("g_avail", "titleclick", "everytime", "g_avail", "sort2", "triggervalue", "add2values") Call Notify("g_select", "titleclick", "everytime", "g_select", "sort2", "triggervalue", "add2values") Call Notify("g_avail", "ACTIVE", "EVERYTIME", "muiApp", "RETURNID") Call Notify("g_select", "ACTIVE", "EVERYTIME", "muiApp", "RETURNID") /* ** Select all button */ Call Notify("g_availAll", "PRESSED", 0, "g_avail", "Select", "All", "On") Call Notify("g_selectAll", "PRESSED", 0, "g_select", "Select", "All", "On") Call Notify("muiPagerList", "ACTIVE", "EVERYTIME", "muiPager", "SET", "ACTIVEPAGE", "TRIGGERVALUE") /* ** Set active gadget at start */ Call Set("muiWin", "ActiveObject", "G_OK") Call set("muiPagerList", "ACTIVE", 0) /* ** Set all the Cycle chains (here, because it will not work above!) */ Call Set("muiPager", "CYCLECHAIN", 1) Call Set("g_top", "CYCLECHAIN", 1) Call Set("g_left", "CYCLECHAIN", 1) Call Set("g_bottom", "CYCLECHAIN", 1) Call Set("g_right", "CYCLECHAIN", 1) Call Set("g_grabMP", "CYCLECHAIN", 1) Call Set("g_pbw", "CYCLECHAIN", 1) Call Set("g_lsize", "CYCLECHAIN", 1) Call Set("g_ffsize", "CYCLECHAIN", 1) Call Set("g_x_num", "CYCLECHAIN", 1) Call Set("g_y_num", "CYCLECHAIN", 1) Call Set("g_f_size", "CYCLECHAIN", 1) Call Set("g_vertical", "CYCLECHAIN", 1) Call Set("g_sbw", "CYCLECHAIN", 1) Call Set("g_thumbSpace", "CYCLECHAIN", 1) Call Set("g_gap", "CYCLECHAIN", 1) Call Set("g_font", "CYCLECHAIN", 1) Call Set("g_printwhat", "CYCLECHAIN", 1) Call Set("g_fsample", "CYCLECHAIN", 1) Call Set("g_scale", "CYCLECHAIN", 1) Call Set("g_sdir", "CYCLECHAIN", 1) Call Set("g_stext", "CYCLECHAIN", 1) Call Set("g_avail", "CYCLECHAIN", 1) Call Set("g_select", "CYCLECHAIN", 1) Call Set("g_availAll", "CYCLECHAIN", 1) Call Set("g_selectAll", "CYCLECHAIN", 1) Call Set("g_ok", "CYCLECHAIN", 1) Call Set("g_cancel", "CYCLECHAIN", 1) Call Set("g_action", "CYCLECHAIN", 1) /* ** Set all the short help texts */ Call Set("g_top", "SHORTHELP", ParseText("Top side of the page")) Call Set("g_left", "SHORTHELP", ParseText("Left side of the page")) Call Set("g_right", "SHORTHELP", ParseText("Right side of the page")) Call Set("g_bottom", "SHORTHELP", ParseText("Bottom side of the page")) Call Set("g_grabMP", "SHORTHELP", ParseText("Get sizes from current MasterPage")) Call Set("g_pbw", "SHORTHELP", ParseText("Weight of page border.")) Call Set("g_lsize", "SHORTHELP", ParseText("Size for text on bottom of the page.")) Call Set("g_ffsize", "SHORTHELP", ParseText("Select a maximum size for the fontsamples\nor the fontsize")) Call Set("g_x_num", "SHORTHELP", ParseText("Number of OverViews per row")) Call Set("g_y_num", "SHORTHELP", ParseText("Number of OverViews per column")) Call Set("g_f_size", "SHORTHELP", ParseText("Maximum fontsize for one sample")) Call Set("g_vertical", "SHORTHELP", ParseText("Place samples vertically instead of horizontally")) Call Set("g_sbw", "SHORTHELP", ParseText("Weight of thumbnail border")) Call Set("g_thumbSpace", "SHORTHELP", ParseText("Space between sample text and border")) Call Set("g_gap", "SHORTHELP", ParseText("Gap between the thumbnails (horizontal AND vertical)")) Call Set("g_font", "SHORTHELP", ParseText("Size for the font names below the thumbnails.\nA textstyle called %bFontName%n will be used!")) Call Set("g_fsample", "SHORTHELP", ParseText("Sample to print for every font.\nYou can use %b*n%n as newline character\nand %b*t%n as tab character.")) Call Set("g_printWhat", "SHORTHELP", ParseText("Use this text, try to print all characters\nor use an external file for samples.")) Call Set("g_scale", "SHORTHELP", ParseText("Scaled to fit or actual size output when selected %bprint%n.")) Call Set("g_sdir", "SHORTHELP", ParseText("Filename for the Catalog (when selected %bsave%n).")) Call Set("g_stext", "SHORTHELP", ParseText("Textfile for the sample text (when selected %buse textfile%n).\nThis can be a pure ascii file or a textfile exported with PageStream3 styles!")) Call Set("g_avail", "SHORTHELP", ParseText("All available fonts (not selected).")) Call Set("g_select", "SHORTHELP", ParseText("These fonts will be printed.")) Call Set("g_action", "SHORTHELP", ParseText("Collect, save or print the Catalog")) Call Set("g_ok", "SHORTHELP", ParseText("Start the Catalog generation")) Call Set("g_cancel", "SHORTHELP", ParseText("Leave program")) Return /* /// */ /* /// BusyClose() */ BusyClose: IF (muiBusyWinOpen = TRUE) THEN DO Call GetAttr("muiBusyWin", "OPEN", "o") IF (o ~= 0) THEN Call Set("muiBusyWin", "OPEN", 0) Call Dispose("muiBusyWin") muiBusyWinOpen = FALSE END Return /* /// */ /* /// BusyHandle(bAnz, current1, current2, current3) */ BusyHandle: PROCEDURE /* ** Handle the mui busy window for font loading... */ PARSE ARG bAnz,current1,current2,current3 IF (bAnz >= 1) THEN Call GetAttr("muiBusyGauge1", "MAX", max1) IF (bAnz >= 2) THEN Call GetAttr("muiBusyGauge2", "MAX", max2) IF (bAnz >= 3) THEN Call GetAttr("muiBusyGauge3", "MAX", max3) IF ((bAnz >= 1) & (current1 >= 0)) THEN Call BusyProgress(1, current1) IF ((bAnz >= 2) & (current2 >= 0)) THEN Call BusyProgress(2, current2) IF ((bAnz >= 3) & (current3 >= 0)) THEN Call BusyProgress(3, current3) /* ** this is the standard cycle to handle an application */ ctrl_C = 2**12 s = 0 Call Handle("muiApp", "H", s) DO i = 0 TO (H.num - 1) id = H.i SELECT WHEN (id = "BUSY_CANCEL") THEN DO userCancel = 1 END END END s = Wait( OR(h.signals, ctrl_C) ) IF (AND(s, ctrl_C) ~= 0) THEN userCancel = 1 Return userCancel /* /// */ /* /// BusyOpen(title, bAnz, text1, text2, text3, total1, total2, total3) */ BusyOpen: /* ** Open a MUI busy requester with a maximum of 3 sliders (should be enough) */ userCancel = 0 PARSE ARG title,bAnz,text1,text2,text3,total1,total2,total3 /* ** let's define the window */ muiBusyWin.ID = "BUSY" muiBusyWin.Title = ParseText(title) muiBusyWin.Contents = "muiBusyGroup" /* ** let's define the window contents ** (simply 3 versions... how lazy!) */ muiBusyGroup.0 = "muiBusyGroup0" muiBusyGroup0.Class = "GROUP" muiBusyGroup0.Frame = "GROUP" muiBusyGroup0.Horiz = 0 muiBusyGroup0.0 = "muiBusyText1" muiBusyText1.Class = "TEXT" muiBusyText1.Contents = ParseText(text1) muiBusyGroup0.1 = "muiBusyGauge1" muiBusyGauge1.Class = "GAUGE" muiBusyGauge1.Frame = "GAUGE" muiBusyGauge1.Horiz = 1 muiBusyGauge1.InfoText = "" muiBusyGauge1.Max = total1 muiBusyGauge1.Current = 0 muiBusyGauge1.FixHeightTxt = 1 IF (bAnz >= 2) THEN DO muiBusyGroup0.2 = "muiBusyText2" muiBusyText2.Class = "TEXT" muiBusyText2.Contents = ParseText(text2) muiBusyGroup0.3 = "muiBusyGauge2" muiBusyGauge2.Class = "GAUGE" muiBusyGauge2.Frame = "GAUGE" muiBusyGauge2.Horiz = 1 muiBusyGauge2.InfoText = "" muiBusyGauge2.Max = total2 muiBusyGauge2.Current = 0 muiBusyGauge2.FixHeightTxt = 1 END IF (bAnz = 3) THEN DO muiBusyGroup0.4 = "muiBusyText3" muiBusyText3.Class = "TEXT" muiBusyText3.Contents = ParseText(text3) muiBusyGroup0.5 = "muiBusyGauge3" muiBusyGauge3.Class = "GAUGE" muiBusyGauge3.Frame = "GAUGE" muiBusyGauge3.Horiz = 1 muiBusyGauge3.InfoText = "" muiBusyGauge3.Max = total3 muiBusyGauge3.Current = 0 muiBusyGauge3.FixHeightTxt = 1 END IF (bAnz = 1) THEN DO muiBusyGroup0.2 = HBar() muiBusyGroup0.3 = Button("BUSY_CANCEL", "_Cancel") END ELSE IF (bAnz = 2) THEN DO muiBusyGroup0.4 = HBar() muiBusyGroup0.5 = Button("BUSY_CANCEL", "_Cancel") END ELSE IF (bAnz = 3) THEN DO muiBusyGroup0.6 = HBar() muiBusyGroup0.7 = Button("BUSY_CANCEL", "_Cancel") END /* ** Busy Cancel Button... */ Call Notify("BUSY_CANCEL", "PRESSED", 0, "muiApp", "SETVAR", "userCancel") /* ** generate new window object */ res = NewObj("WINDOW","muiBusyWin",,1) IF (res ~= 0) THEN Call err(res) muiBusyWinOpen = TRUE /* ** Set active gadget at start */ Call Set("muiBusyWin", "ActiveObject", "BUSY_CANCEL") /* ** to let the window be a bit larger.... */ Call Set("muiBusyGauge1", "INFOTEXT", ".............................................................................") /* ** Add window to application */ Call Add("muiApp", "muiBusyWin") Call Set("muiBusyWin", "OPEN", 1) Call GetAttr("muiBusyWin", "OPEN", "o") IF (o = 0) THEN DO Say "can't open busy window!" Call ShowRequester("Can't open busy window! -> Exiting", "Sorry...") Call CleanUp END Return 1 /* /// */ /* /// BusyProgress(nr, current) */ BusyProgress: PROCEDURE /* ** Set a new progress */ PARSE ARG nr,current IF (nr = 1) THEN DO Call GetAttr("muiBusyGauge1", "MAX", max) Call Set("muiBusyGauge1", "CURRENT", Trunc(current)) Call Set("muiBusyGauge1", "INFOTEXT", Trunc(100*current/max) ||"%") END ELSE IF (nr = 2) THEN DO Call GetAttr("muiBusyGauge2", "MAX", max) Call Set("muiBusyGauge2", "CURRENT", Trunc(current)) Call Set("muiBusyGauge2", "INFOTEXT", Trunc(100*current/max) ||"%") END ELSE IF (nr = 3) THEN DO Call GetAttr("muiBusyGauge3", "MAX", max) Call Set("muiBusyGauge3", "CURRENT", Trunc(current)) Call Set("muiBusyGauge3", "INFOTEXT", Trunc(100*current/max) ||"%") END Return userCancel /* /// */ /* /// BusyText(nr, text) */ BusyText: /* ** Set a new text for one gauge in the busy requester */ PARSE ARG nr,text IF (nr = 1) THEN Call Set("muiBusyText1", "CONTENTS", ParseText(text)) IF (nr = 2) THEN Call Set("muiBusyText2", "CONTENTS", ParseText(text)) IF (nr = 3) THEN Call Set("muiBusyText3", "CONTENTS", ParseText(text) Return /* /// */ /* /// CheckPrefsVersion(fileName) */ CheckPrefsVersion: /* ** Check if prefsfile is compatible ** -------------------------------- */ PARSE ARG fileName IF (fileName = "") THEN fileName = standardPrefs ok = Open('Prefs', fileName, 'R') IF (ok = 1) THEN DO dummy = ReadLn('Prefs') cl = Close('Prefs') IF ( (Left(dummy, Length(pgsName)) = pgsName) | (Left(dummy, 3) = 'FSP') ) & (Right(dummy,4) >= pgsLVer) THEN Return 0 END RETURN 1 /* /// */ /* /// CheckRoutines() */ CheckRoutines: ADDRESS "PAGESTREAM" 'CURRENTWINDOWPATH' oldWinName = RESULT 'GETPAGEMASTERPAGE MASTERPAGE mname WINDOW "'oldwinname'"' IF (RC = 10) THEN DO Call ShowRequester('Please open a new Document first.') ADDRESS PAGESTREAM 'LOCKINTERFACE FALSE' Call CleanUp() EXIT END 'CURRENTPAGE WINDOW "'oldwinname'"' pagenumber = RESULT IF ((pageNumber < 1) | (pageNumber > 999999)) THEN DO /* maybe the user started from the masterpage?? */ Call ShowRequester('Please go to a valid page and start again!') ADDRESS PAGESTREAM 'LOCKINTERFACE FALSE' Call CleanUp() EXIT END Return /* /// */ /* /// CleanUp() */ CleanUp: ADDRESS PAGESTREAM /* ** Close busy requester, clean up and leave program ** ------------------------------------------------ */ IF (muiBusyWinOpen = TRUE) THEN DO Call BusyClose() END /* ** reset the measurementsystem to the saved one!! */ ''defmeasure'' 'REFRESH ON' 'REFRESHWINDOW WINDOW "'|| oldWinName ||'"' 'LOCKINTERFACE FALSE' EXIT /* /// */ /* /// ConvertRawText2rxMUI(rawText) */ ConvertText2hex: PARSE ARG rawText rawHex = c2x(rawText) rawHex2 = '' DO k = 1 TO Length(rawHex) char = SubStr(rawHex, k, 2) SELECT /* line feed */ WHEN char = '0A' THEN DO rawHex2 = rawHex2 || c2x('\n') END /* percent */ WHEN char = '25' THEN DO rawHex2 = rawHex2 || c2x('\%') END OTHERWISE rawHex2 = rawHex2 || char END k = k + 1 END Return rawHex2 /* /// */ /* /// ConvertTextToMultipleLines(src) */ ConvertTextToMultipleLines: PARSE ARG src _num = 1 _dest.num = _num _dest.0 = src DO FOREVER _prev = _num-1 pos = Index(_dest._prev, '\n') IF (pos = 0) THEN LEAVE _dest._num = SubStr(_dest._prev, pos+2) _dest._prev = Left(_dest._prev, pos-1) _num = _num + 1 END _dest.num = _num Return /* /// */ /* /// ConvertToShortMeasurement(inp) */ /*************************************************/ /* convert long measurement to short measurement */ /* (CENTIMETERS -> cm ...) */ /*************************************************/ ConvertToShortMeasurement: PARSE ARG inp long = 'INCHES CENTIMETERS MILLIMETERS PICAS POINTS PRINTERPICAS PRINTERPOINTS CICEROS DIDOTPOINTS FEET METERS' short = 'i cm mm p pt pp ppt c d f m' outp = '' DO k = 1 to Words(long) IF ( Word(long, k) = inp ) THEN outp = Word(short, k) END IF (outp = '') THEN DO DO k = 1 to Words(long) IF (Word(long, k) = inp) THEN outp = Word(short, k) END END Return outp /* /// */ /* /// DoAllFonts */ DoAllFonts: /* current number of pics per page */ nppp = 0 DO fontNum = 0 TO anzFonts-1 lastpic = 0 Call AddObject(fonts.fontNum) IF (lastpic = 1) THEN DO /* last thumbnail on page */ IF (BusyHandle(1, fontNum, 0, 0) = 1) THEN DO Call CleanUp() EXIT END Call BusyText(2, "%c%brefreshing display%n\n%c...%n") Call BusyProgress(2, 100) 'REFRESH ON' 'REFRESHWINDOW WINDOW "'|| oldWinName || '"' IF (prefs.PV_action = 1) THEN Call PrintPage ELSE IF (prefs.PV_action = 2) THEN Call SaveDocument pagenumber = pagenumber + 1 'DISPLAY PAGE "'|| pageNumber ||'" WINDOW "'|| oldWinName ||'"' nppp = 0 'REFRESH OFF' END END Return /* /// */ /* /// DrawTextObject() */ DrawTextObject: PARSE ARG name say name ffs_size 'DRAWTEXTOBJ 'd1 d2' INFRONT WINDOW "'oldwinname'"' txtid = RESULT 'SELECTTEXT INOBJECT 'txtid' WINDOW "'oldwinname'"' 'BEGINCOMMANDCAPTURE' 'SETTRACKTABLE NONE' 'SETLEADING RELATIVE 100%' 'SETTYPESIZE 'ffs_size 'ENDCOMMANDCAPTURE' 'SETFONT "'name'" WINDOW "'oldwinname'"' /* print buffer instead of generating new textsample */ IF (fontNum > 0) THEN DO Call BusyText(2, "%c%binserting buffer%n\n%c...%n") Call BusyProgress(2, 100) 'INSERTTEXT RETAINFORMAT TRUE TEXTCODE "PageStream" FILE "T:FontSample.TXT" FILTER "IFFCTXT" NOSTATUS' 'SELECTTEXT ALL INOBJECT 'txtid' WINDOW "'oldwinname'"' /* ** insert font name if wanted */ 'REPLACETEXT FIND "\%FN" REPLACE "'|| name ||'" ALL WHOLEWORDS TRUE CASESENSITIVE FALSE IGNOREACCENTS TRUE ARTICLE' END ELSE DO SELECT WHEN (prefs.PV_printWhat = 1) THEN DO /* ** generate almost all character samples */ n = 0 Call BusyText(2, "%c%btrying to print all characters%n\n%c...%n") Call BusyProgress(2, n) codes = '32-64,0,' codes = codes || '65-90,0,' codes = codes || '91-122,0,' codes = codes || '123-127,160-190,0,' codes = codes || '191-215,0,' codes = codes || '216-247,0,' codes = codes || '248-255,305-307,320-322,329,338-339,352-353,381-382,402,0,' codes = codes || '768-780,807-808,915-917,920,923,926,928,931,933-934,936,937,0,' codes = codes || '945-961,963-969,977,981-982,987-988,0,' codes = codes || '1489-1490,9184-8195,8201,8211-8212,8216-8218,8220-8222,8224-8226,8230,8240,8242-8243 ' ende = 0 DO WHILE (ende = 0) pos = POS(',', codes) IF (pos = 0) THEN DO pos = length(codes) ende = 1 END /* if pos */ part = left(codes, pos-1) codes = right(codes, (length(codes) - pos)) pos = POS('-', part) IF (pos = 0) THEN DO von = part bis = part END /* if pos */ ELSE DO von = left(part, pos-1) bis = right(part, length(part) - pos) END /* else do */ IF (von = 0) THEN DO n = n + (100/9) IF (BusyHandle(2, 0, n, 0) = 1) THEN DO Call CleanUp() EXIT END 'INSERTCONTROL NEWLINE' END /* end if von */ ELSE DO DO x = von TO bis xx = '0000'||x 'INSERTCHAR UNICODE '|| substr(xx, length(xx)-3,4) END /* do x */ END /* else do */ END /* do */ END /* when */ WHEN (prefs.PV_printWhat = 2) THEN DO /* use textfile for sample text - ask user how to import it!*/ 'INSERTTEXT FILE "'|| prefs.PV_sText ||'"' END /* when */ OTHERWISE DO /* ** print user defined fontsample */ /* ** abbreviations for the text ** %FONTNAME / %FN : current font name */ DO tk = 0 TO (prefs.fSample.num - 1) infoText.tk = prefs.fSample.tk /* Picture Name */ infoText.tk = ReplaceItemInText(infoText.tk, '\%FONTNAME', '\%FN') /* infoText.tk = ReplaceItemInText(infoText.tk, '\%FN', name) */ END DO tk = 0 TO (prefs.fSample.num - 1) 'INSERT "'|| infoText.tk ||'" WINDOW "'oldwinname'"' IF (tk < (prefs.fSample.num - 1)) THEN DO 'INSERTCONTROL NEWLINE WINDOW "'oldwinname'"' END END END /* WHEN */ END /* SELECT */ /* ** first textsample. copy the content to speed up the following ones by just pasting it */ 'SELECTTEXT ALL INOBJECT 'txtid' WINDOW "'oldwinname'"' 'EXPORTTEXT RETAINFORMAT FALSE TEXTCODE "PageStream" FILE "T:FontSample.TXT" FILTER "IFFCTXT" STATUS FORCE' /* ** insert font name if wanted */ 'REPLACETEXT FIND "\%FN" REPLACE "'|| name ||'" ALL WHOLEWORDS TRUE CASESENSITIVE FALSE IGNOREACCENTS TRUE ARTICLE' END /* if fontNum */ 'GETTEXTOBJ POSITION posi OBJECTID 'txtid' WINDOW "'oldwinname'"' txtid = RESULT Return /* /// */ /* /// DrawPageBorder() */ DrawPageBorder: 'DISPLAY MPG RIGHT WINDOW "'oldwinname'"' d1 = leftgap + pbw/2 d2 = topgap + pbw/2 d3 = pagesizex-rightgap - pbw/2 d4 = pagesizey-bottomgap - pbw/2 - (lsize+1) 'DRAWBOX 'd1 d2 d3 d4' WINDOW "'oldwinname'"' dummy = RESULT 'SETSTROKEWEIGHT 'pbw' OBJECTID 'dummy 'SETSTROKEJOIN ROUND OBJECTID 'dummy IF (lsize > 0) THEN DO d1 = d1 - pbw/2 d3 = d3 + pbw/2 d4 = d4 + pbw/2 + 1 'DRAWTEXTOBJ 'd1 d4' INFRONT WINDOW "'oldwinname'"' txtid = RESULT 'SELECTTEXT INOBJECT 'txtid' WINDOW "'oldwinname'"' bottomtwidth = d3 - d1 'BEGINCOMMANDCAPTURE' 'SETTRACKTABLE NONE' 'SETLEADING RELATIVE 100%' 'SETTYPESIZE "'lsize'"' 'ENDCOMMANDCAPTURE' 'INSERT "'|| pgsName pgsVersion ||' - '|| pgsCopy ||'" WINDOW "'oldwinname'"' 'SETTABRULER "RIGHT" 'bottomtwidth' WINDOW "'oldwinname'"' 'INSERTCONTROL TAB WINDOW "'oldwinname'"' 'INSERT "Page " WINDOW "'oldwinname'"' 'INSERTNUMBER PAGE WINDOW "'oldwinname'"' END 'DISPLAY PAGE 'pagenumber' WINDOW "'oldwinname'"' Return /* /// */ /* /// err(res) */ err: PARSE ARG res ADDRESS 'PAGESTREAM' 'LOCKINTERFACE FALSE' 'REFRESH ON' 'REFRESHWINDOW WINDOW "'|| oldWinName ||'"' ''defmeasure'' Call pgsRequester(GetRXmuiString(res) "in line" sigl-1) Exit /* /// */ /* /// EventLoop() */ EventLoop: /* ** this is the standard cycle to handle an application */ ctrl_C = 2**12 s = 0 DO FOREVER Call Handle("muiApp", "H", s) ws = 0 DO i = 0 TO (H.num - 1) id = H.i SELECT WHEN (id = "G_AVAIL" ) | (id = "G_SELECT" ) THEN DO Call SetListTitles() END WHEN (id = "QUIT") | (id = "G_CANCEL") THEN DO Call CleanUp EXIT END WHEN (id = "G_GRABMP") THEN DO Call PrefsWindowGet() Call GrabMasterPage() Call PrefsWindowSet() END WHEN (id = "MUIMENULOAD") THEN DO Call LoadPrefsAs() Call PrefsWindowSet() END WHEN (id = "MUIMENUSAVE") THEN DO Call PrefsWindowGet() Call SavePrefs() Call PrefsWindowSet() END WHEN (id = "MUIMENUSAVEAS") THEN DO Call PrefsWindowGet() Call SavePrefsAs() Call PrefsWindowSet() END WHEN (id = "MUIMENUQUIT") THEN DO IF (ShowRequester('Really Quit?', 'No|Yes') = 0) THEN DO Call CleanUp EXIT END END WHEN (id = "G_OK") THEN DO Return END OTHERWISE Say h.i END END IF (~ws) THEN Iterate s = Wait( OR(h.signals, ctrl_C) ) IF (AND(s, ctrl_C) ~= 0) THEN EXIT END EXIT /* /// */ /* /// FontCatalog() */ FontCatalog: ADDRESS 'PAGESTREAM' defmeasure = GetDefaultMeasurementSystem() 'GETDIMENSIONS dim MASTERPAGE "'mname'" WINDOW "'oldwinname'"' IF (dim.orientation = 'PORTRAIT') THEN DO rpagesizex = dim.width rpagesizey = dim.height END ELSE DO rpagesizex = dim.height rpagesizey = dim.width END Call ConvertTextToMultipleLines(x2c(prefs.PV_fSample)) prefs.fSample.num = _dest.num DO k = 0 TO (_dest.num - 1) prefs.fSample.k = _dest.k END leftGap = p2d(prefs.PV_left, measure) rightGap = p2d(prefs.PV_right, measure) topGap = p2d(prefs.PV_top, measure) bottomGap = p2d(prefs.PV_bottom, measure) pbw = p2d(prefs.PV_pbw, measure) lsize = p2d(prefs.PV_lSize, measure) thumbSpace = p2d(prefs.PV_thumbSpace, measure) gap = p2d(prefs.PV_gap, measure) sbw = p2d(prefs.PV_sbw, measure) txtSize = p2d(prefs.PV_font, measure) startx = leftgap + (pbw + gap) starty = topgap + (pbw + gap) /* some more defaults and transformations */ maxheight = 0 maxwidth = 0 IF (prefs.PV_ffSize = 1) THEN ffs_size = p2d(prefs.PV_f_size, measure) ELSE ffs_size = 15 pagesizex = rpagesizex pagesizey = rpagesizey IF (prefs.PV_ffSize = 0) THEN DO /* horizontal and vertical sizes for one fontsample */ /* including: border, sample and text */ /* excluding: gap between thumbnails. */ /****************************************************/ psx = (pagesizex - leftGap - rightGap - (2*pbw) - (prefs.PV_x_num+1)*gap) / prefs.PV_x_num psy = (pagesizey - topGap - bottomGap - (lsize+1) - (2*pbw) - (prefs.PV_y_num+1)*gap) / prefs.PV_y_num /* psy without the text under it */ psynt = psy - (txtsize+1) /* horizontalsize/verticalsize */ psf = (psx-2*(sbw+1)) / (psynt-2*(sbw+1)) /* number of samples/page */ anzp = prefs.PV_x_num * prefs.PV_y_num END fontNum = 0 /* ** draw border for first page */ CALL DrawPageBorder 'REFRESH OFF' CALL DoAllFonts IF (nppp=0) THEN 'DELETEPAGE' IF (nppp > 0) THEN DO IF (prefs.PV_action = 1) THEN DO /* ready but not yet printed */ Call BusyText(2, "%c%brefreshing display%n\n%c...%n") Call BusyProgress(2, 50) 'REFRESH ON' 'REFRESHWINDOW WINDOW "'|| oldWinName ||'"' CALL PrintPage END IF (prefs.PV_action = 2) THEN DO /* ready but not yet saved */ Call BusyText(2, "%c%brefreshing display%n\n%c...%n") Call BusyProgress(2, 50) 'REFRESH ON' 'REFRESHWINDOW WINDOW "'|| oldWinName ||'"' CALL SaveDocument END END Call CleanUp() EXIT /* /// */ /* /// GetDefaultMeasurementSystem() */ GetDefaultMeasurementSystem: PROCEDURE 'GETMEASUREMENTS COORDINATE stemc RELATIVE rel TEXT tex FROM fro' st = 'SETMEASUREMENTS COORDINATE 'stemc.horizontal stemc.vertical' RELATIVE 'rel' TEXT 'tex' FROM 'fro 'SETMEASUREMENTS COORDINATE POINTS SAMEAS RELATIVE SAMEAS TEXT POINTS FROM PAGE' Return st /* /// */ /* /// GetFileName(prefName) */ GetFileName: PARSE ARG fileName,text file = FilePart(fileName) path = PathPart(fileName) 'GETFILE TITLE "'|| text ||'" PATH "'|| path ||'" FILE "'|| file ||'"' IF (RC = 0) THEN fileName = RESULT ELSE fileName = 0 Return fileName /* /// */ /* /// GetFontList() */ GetFontList: ADDRESS PAGESTREAM 'GETFONTLIST fonts' anzFonts = RESULT busyReq = BusyOpen("getting font list...", 1, "%b%creading font...%n\n%c", "", "", anzFonts-1, 0, 0) percent10 = 0.1 * anzFonts currentPERC = 0 DO k=0 TO (anzFonts - 1) Call DoMethod("G_SELECT", "INSERT", fonts.k, "SORTED") IF (k >= currentPERC) THEN DO DO WHILE ( (k >= currentPERC) & (percent10 > 0) ) currentPERC = currentPERC + percent10 END Call BusyText(1, "%b%creading font...%n\n%c"|| fonts.k ||"%n") IF (BusyHandle(1, k, 0, 0) = 1) THEN DO Call CleanUp(busyReq) EXIT END END END Call SetListTitles() Call BusyClose() RETURN /* /// */ /* /// GrabMasterPage() */ GrabMasterPage: ADDRESS 'PAGESTREAM' 'GETPAGEMASTERPAGE MASTERPAGE mname' IF (RC = 10) THEN DO Call ShowRequester('Please open a new Document first! Quit now!') Return END 'GETMEASUREMENTS COORDINATE stemc' IF (stemc.vertical = 'SAMEAS') THEN stemc.vertical = stemc.horizontal 'GETMARGINGUIDES guides' prefs.PV_left = guides.inside || ConvertToShortMeasurement(stemc.horizontal) prefs.PV_right = guides.outside || ConvertToShortMeasurement(stemc.horizontal) prefs.PV_top = guides.top || ConvertToShortMeasurement(stemc.vertical) prefs.PV_bottom = guides.bottom || ConvertToShortMeasurement(stemc.vertical) Return /* /// */ /* /// LoadPrefs(fileName) */ LoadPrefs: /* ** load the preferences file ** ------------------------- */ PARSE ARG fileName IF (fileName = "") THEN fileName = standardPrefs say 'loading 'fileName' ...' /* ** Check the version of the prefs file */ IF (CheckPrefsVersion(fileName) ~= 0) THEN DO Call ShowRequester('Prefsfile not found or not valid! Using defaults.', 'Hmm...') Return END ELSE DO Call Open('Prefs', fileName, 'R') Say 'Reading prefs file...' dummy = ReadLN('Prefs') DO xx = 1 to 100 command = ReadLn('Prefs') INTERPRET command IF EOF('Prefs') THEN LEAVE END Call Close('Prefs') END RETURN /* /// */ /* /// LoadPrefsAs() */ LoadPrefsAs: /* ** Load Prefs with selectable name ** ------------------------------- */ prefName = GetFileName(currentPrefs, 'Load Preferences...') IF (prefName ~= 0) THEN DO currentPrefs = prefName Call LoadPrefs(currentPrefs) END Return /* /// */ /* /// pgsRequester(text) */ pgsRequester: PARSE ARG meldung /* ** Convert to multiple lines */ _num = 1 mLines.num = _num mLines.0 = meldung DO FOREVER _prev = _num-1 pos = Index(mLines._prev, '|') IF (pos = 0) THEN LEAVE mLines._num = SubStr(mLines._prev, pos+1) mLines._prev = Left(mLines._prev, pos-1) _num = _num + 1 END mLines.num = _num l = 0 DO kk = 0 TO mLines.num - 1 IF (l < Length(mLines.kk) * 8) THEN l = Length(mLines.kk) * 8 Say mLines.kk END ADDRESS "PAGESTREAM" 'ALLOCAREXXREQUESTER "error inside '|| pgsName ||'" '|| (l+20) (40 + mLines.num * 10) reqhandle = RESULT 'ADDAREXXGADGET '|| reqhandle ||' EXIT '|| (l/2 - 25) (20 + mLines.num * 10) ||' 50 LABEL "_Ok"' dummy = RESULT DO kk = 0 TO mLines.num - 1 'ADDAREXXGADGET 'reqhandle' TEXT 10 ' (10 + kk*10) l 'STRING "'mLines.kk'"' END 'DOAREXXREQUESTER 'reqhandle dummy = RESULT 'FREEAREXXREQUESTER 'reqhandle RETURN /* /// */ /* /// PrefsWindowGet() */ PrefsWindowGet: Call GetAttr("g_top", "CONTENTS", "prefs.PV_top") Call SetCorrectMSys('prefs.PV_top') Call GetAttr("g_left", "CONTENTS", "prefs.PV_left") Call SetCorrectMSys('prefs.PV_left') Call GetAttr("g_bottom", "CONTENTS", "prefs.PV_bottom") Call SetCorrectMSys('prefs.PV_bottom') Call GetAttr("g_right", "CONTENTS", "prefs.PV_right") Call SetCorrectMSys('prefs.PV_right') Call GetAttr("g_pbw", "CONTENTS", "prefs.PV_pbw") Call SetCorrectMSys('prefs.PV_pbw') Call GetAttr("g_lsize", "CONTENTS", "prefs.PV_lsize") Call SetCorrectMSys('prefs.PV_lsize') Call GetAttr("g_ffsize", "ACTIVE", "prefs.PV_ffSize") Call GetAttr("g_printwhat", "ACTIVE", "prefs.PV_printWhat") Call GetAttr("g_scale", "ACTIVE", "prefs.PV_scale") Call GetAttr("g_action", "ACTIVE", "prefs.PV_action") Call GetAttr("g_x_num", "VALUE", "prefs.PV_x_num") Call GetAttr("g_y_num", "VALUE", "prefs.PV_y_num") Call GetAttr("g_f_size", "CONTENTS", "prefs.PV_f_size") Call SetCorrectMSys('prefs.PV_f_size') Call GetAttr("g_vertical", "SELECTED", "prefs.PV_vertical") Call GetAttr("g_sbw", "CONTENTS", "prefs.PV_sbw") Call SetCorrectMSys('prefs.PV_sbw') Call GetAttr("g_thumbSpace", "CONTENTS", "prefs.PV_thumbSpace") Call SetCorrectMSys('prefs.PV_thumbSpace') Call GetAttr("g_gap", "CONTENTS", "prefs.PV_gap") Call SetCorrectMSys('prefs.PV_gap') Call GetAttr("g_font", "CONTENTS", "prefs.PV_font") Call SetCorrectMSys('prefs.PV_font') Call GetAttr("g_fsample", "CONTENTS", "rawText") prefs.PV_fSample = ConvertText2hex(rawText) Call GetAttr("g_sdir", "CONTENTS", "prefs.PV_sdir") Call GetAttr("g_stext", "CONTENTS", "prefs.PV_stext") /* ** also get the selected font list */ Call DoMethod("G_SELECT", "GETENTRIES", fonts) anzFonts = fonts.num+1 Return /* /// */ /* /// PrefsWindowSet() */ PrefsWindowSet: Call Set("g_top", "CONTENTS", prefs.PV_top) Call Set("g_left", "CONTENTS", prefs.PV_left) Call Set("g_bottom", "CONTENTS", prefs.PV_bottom) Call Set("g_right", "CONTENTS", prefs.PV_right) Call Set("g_pbw", "CONTENTS", prefs.PV_pbw) Call Set("g_lsize", "CONTENTS", prefs.PV_lsize) Call Set("g_ffsize", "ACTIVE", prefs.PV_ffSize) Call Set("g_printwhat", "ACTIVE", prefs.PV_printWhat) Call Set("g_scale", "ACTIVE", prefs.PV_scale) Call Set("g_action", "ACTIVE", prefs.PV_action) Call Set("g_x_num", "VALUE", prefs.PV_x_num) Call Set("g_y_num", "VALUE", prefs.PV_y_num) Call Set("g_f_size", "CONTENTS", prefs.PV_f_size) Call Set("g_vertical", "SELECTED", prefs.PV_vertical) Call Set("g_sbw", "CONTENTS", prefs.PV_sbw) Call Set("g_thumbSpace", "CONTENTS", prefs.PV_thumbSpace) Call Set("g_gap", "CONTENTS", prefs.PV_gap) Call Set("g_font", "CONTENTS", prefs.PV_font) Call Set("g_fsample", "CONTENTS", ParseText(x2c(prefs.PV_fsample))) Call Set("g_sdir", "CONTENTS", prefs.PV_sdir) Call Set("g_stext", "CONTENTS", prefs.PV_stext) Return /* /// */ /* /// PrintPage() */ PrintPage: Call BusyText(2, "%c%bprinting page%n\n%c"|| pagenumber ||"%n") Call BusyProgress(2, 100) IF (prefs.PV_scale = 0) THEN DO 'PRINTDOCUMENT PAGE "" OUTPUT GRAYSCALE SCALE "ACTUAL"' END IF (prefs.PV_scale = 1) THEN DO 'PRINTDOCUMENT PAGE "" OUTPUT GRAYSCALE SCALE "FULLPAGE"' END Call BusyText(2, "%c%bdeleting page%n\n%c...%n") Call BusyProgress(2, 50) 'SELECTOBJECT ALL WINDOW "'oldwinname'"' Call BusyProgress(2, 100) 'DELETEOBJECT WINDOW "'oldwinname'"' Return /* /// */ /* /// ReplaceItemInText(src, item, new) */ ReplaceItemInText: PARSE ARG src,item,new /* ** prepare the thumbnail text */ dest = src pos = Index(dest, item) IF (pos > 0) THEN DO dest = DelStr(dest, pos, Length(item)) dest = Insert(new, dest, pos-1) END Return dest /* /// */ /* /// SaveDocument() */ SaveDocument: Call BusyText(2, "%c%bsaving document%n\n%c"|| prefs.PV_sDir ||"%n") Call BusyProgress(2, 100) 'SAVEDOCUMENT FILE "'|| prefs.PV_sDir ||'" FILTER IFFDOC STATUS FORCE' Return /* /// */ /* /// SavePrefs(fileName) */ SavePrefs: /* ** save the preferences file ** ------------------------- */ PARSE ARG filename IF (fileName = "") THEN fileName = standardPrefs say 'saving 'fileName' ...' okOpen = Open('Prefs', fileName, 'W') IF (okOpen = 1) THEN DO OPTIONS FAILAT 11 Say 'writing prefs "'|| fileName ||'"...' WriteLN('Prefs', pgsName pgsVersion) Call WritePrefsNameValue('Prefs', 'prefs.PV_top') Call WritePrefsNameValue('Prefs', 'prefs.PV_left') Call WritePrefsNameValue('Prefs', 'prefs.PV_bottom') Call WritePrefsNameValue('Prefs', 'prefs.PV_right') Call WritePrefsNameValue('Prefs', 'prefs.PV_pbw') Call WritePrefsNameValue('Prefs', 'prefs.PV_lsize') Call WritePrefsNameValue('Prefs', 'prefs.PV_ffSize') Call WritePrefsNameValue('Prefs', 'prefs.PV_printWhat') Call WritePrefsNameValue('Prefs', 'prefs.PV_x_num') Call WritePrefsNameValue('Prefs', 'prefs.PV_y_num') Call WritePrefsNameValue('Prefs', 'prefs.PV_f_size') Call WritePrefsNameValue('Prefs', 'prefs.PV_vertical') Call WritePrefsNameValue('Prefs', 'prefs.PV_sbw') Call WritePrefsNameValue('Prefs', 'prefs.PV_thumbSpace') Call WritePrefsNameValue('Prefs', 'prefs.PV_gap') Call WritePrefsNameValue('Prefs', 'prefs.PV_font') Call WritePrefsNameValue('Prefs', 'prefs.PV_fsample') Call WritePrefsNameValue('Prefs', 'prefs.PV_scale') Call WritePrefsNameValue('Prefs', 'prefs.PV_sdir') Call WritePrefsNameValue('Prefs', 'prefs.PV_stext') Call WritePrefsNameValue('Prefs', 'prefs.PV_action') WriteLN('Prefs', '/* END OF Prefsfile for '|| pgsName pgsVersion ||' ('|| pgsDate ||') */') OPTIONS FAILAT 10 Call Close('Prefs') END ELSE DO Say 'Error writing prefs file "'|| fileName ||'"' Call ShowRequester('ERROR writing prefs file '|| fileName, 'Damn!') END RETURN /* /// */ /* /// SavePrefsAs() */ SavePrefsAs: /* ** Save Prefs with selectable name ** ------------------------------- */ prefName = GetFileName(currentPrefs, 'Save Preferences As...') IF (prefName ~= 0) THEN DO currentPrefs = prefName Call SavePrefs(currentPrefs) END Return /* /// */ /* /// SetCorrectMSys(vName) */ SetCorrectMSys: PARSE ARG vName Interpret vName || ' = p2d('|| vName || ', mSys('|| vName ||')) || mSys('|| vName ||')' Return /* /// */ /* /// SetDefaultPrefs() */ SetDefaultPrefs: /* ** defaults needed in the program */ measure = 'pt' tf.0 = 'FALSE' tf.1 = 'TRUE' Progress = 0 currentPrefs = standardPrefs prefs.PV_left = '1cm' prefs.PV_right = '1cm' prefs.PV_top = '1cm' prefs.PV_bottom = '1cm' prefs.PV_pbw = '3pt' prefs.PV_lsize = '12pt' prefs.PV_x_num = '4' prefs.PV_y_num = '6' prefs.PV_f_size = '20pt' prefs.PV_vertical = '0' prefs.PV_thumbSpace = '1mm' prefs.PV_gap = '5mm' prefs.PV_sbw = '1pt' prefs.PV_font = '10pt' prefs.PV_fSample = ConvertText2hex('%FONTNAME\nabc\nABC') prefs.PV_sdir = 'RAM:' prefs.PV_stext = 'RAM:FontSample.iff' prefs.PV_size = '12pt' prefs.PV_scale = '0' prefs.PV_printWhat = '0' prefs.PV_action = '0' prefs.errorSkip = 0 Return /* /// */ /* /// SetListTitles() */ SetListTitles: PROCEDURE Call GetAttr("G_AVAIL", "ENTRIES", a_anz) Call GetAttr("G_SELECT", "ENTRIES", s_anz) Call Set("AVAILTEXT", "CONTENTS", ParseText('%c%8 'a_anz' %nfonts available')) Call Set("SELECTTEXT", "CONTENTS", ParseText('%c%8 's_anz' %nfonts available')) RETURN /* /// */ /* /// ShowRequester(question, knobs) */ ShowRequester: /* ** Show requester with some gadgets ** -------------------------------- */ PARSE ARG question,knobs Say question reqData = EasyRequest(question, pgsNAme, knobs) say reqData Return reqData /* /// */ /* /// SizeError() */ SizeError: res = ShowRequester("Current sample is too big to fit","skip|skip all|stop") IF (res = 0) THEN DO Call CLEANUP Exit END Return res /* /// */ /* /// WritePrefsNameValue(file, name) */ WritePrefsNameValue: /* ** write parameter with value in file ** ---------------------------------- */ PARSE ARG file,name Interpret "saveSTR = '"|| name ||" = ""'"|| name ||"'""'" WriteLN(file, saveSTR) Return /* /// */ /* /// ON SYNTAX */ SYNTAX: f = rc str = "*-------------------------------------------*" str = str || '|' || "* Syntax Error in line "|| sigl str = str || '|' || "* "|| f ||":" ErrorText(f) str = str || '|' || "*-------------------------------------------*" /* ** Unlock PageStream and QUIT */ ADDRESS 'PAGESTREAM' 'LOCKINTERFACE FALSE' 'REFRESH ON' 'REFRESHWINDOW WINDOW "'|| oldWinName ||'"' ''defmeasure'' Call pgsRequester(str) IF (f = 15) THEN DO Call pgsRequester('You should consider to register rxMUI.|Looks like the trial time is over.') END EXIT /* /// */